// 封装一个线程
#pragma once
#include <iostream>
#include <string>
#include <functional>
#include <cstdio>
#include <pthread.h>
typedef void *(*func_t)(void *);
class ThreadData
{
public:
    std::string _name;
    void* _args;
};
class Thread
{
public:
    Thread(int num, func_t func, void *args)
        : _func(func)
    {
        char name_buffer[64];
        snprintf(name_buffer,sizeof(name_buffer),"Thread-%d",num);
        _thread_data._name = name_buffer;
        _thread_data._args = args;
    }

    void start()
    {
        pthread_create(&_tid,nullptr,_func,(void*)&_thread_data);
    }
    void join()
    {
        pthread_join(_tid,nullptr);
    }
    ~Thread()
    {
        
    }


private:
    func_t _func;
    ThreadData _thread_data;
    pthread_t _tid;
};